package br.com.jw.controle;


import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;

import br.com.jw.dao.MenusDao;
import br.com.jw.jdbc.Pool;
import br.com.jw.modelo.Menu;

public class ThreadMenus extends Thread{
	private Socket socket;
	boolean  aux=false;
    private Pool pool=new Pool();
    
	public ThreadMenus(Socket socket){
		this.socket=socket;
	}
	public void run(){
		
		
		try{
			DataInputStream in=new DataInputStream(socket.getInputStream());
			DataOutputStream out=new DataOutputStream(socket.getOutputStream());
			String modo=in.readUTF();
			
			
			 if(modo.equals("listarMenus")){
				MenusDao menusDao=new MenusDao(pool);
				String dados="";
				for(Menu m: menusDao.listaMenus()){
					dados+=m.getMen_id()+",";
					dados+=m.getMen_nome()+",";
					
				}				
				out.writeUTF(dados);
				}
			
			out.close();
			in.close();
			socket.close();
		
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
